import VNode from './VNode';

export default function h(sel,data,c) {
    let children = []
    if(typeof c == "number" || typeof c == 'string') {
        return VNode(sel, data, undefined, c, undefined)
    }
    // 如果c是children[h()]或h()
    else if (Array.isArray(c) && c.length > 0) {
        c.forEach(el => {
            children.push(el)
        })
        return VNode(sel, data, children, undefined, undefined)
    }

    else if(Object.prototype.toString.call(c) == '[object Object]') {
        children = [c]
        return VNode(sel, data, children, undefined, undefined)
    }
}
